import 'package:app_health/widget/numberpicker.dart';
import 'package:flutter/material.dart';

/// 生日
class DataWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return DataWidgetState();
  }
}

class DataWidgetState extends State<DataWidget> {
  var topText = Column(
    children: <Widget>[
      Container(
        margin: EdgeInsets.only(top: 60.0),
        width: double.infinity,
        alignment: Alignment.center,
        child: Text(
          '请选择你的年龄',
          style: TextStyle(fontSize: 18.0),
        ),
      ),

    ],
  );

  int wight = 76;

  Widget showHigh() {
    return Container(
      margin: EdgeInsets.only(top: 40.0),
      child: Row(
        verticalDirection: VerticalDirection.down,
        crossAxisAlignment: CrossAxisAlignment.end,
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Text(
            wight.toString(),
            style: TextStyle(fontSize: 25.0),
          ),
          Text(
            '公斤',
            style: TextStyle(fontSize: 12.0),
          )
        ],
      ),
    );
  }

  Widget bottom2Btn() {
    return Container(
      alignment: Alignment.bottomCenter,
      width: double.infinity,
      margin: EdgeInsets.only(top: 20.0, left: 30.0, right: 30.0),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Expanded(
              child: RaisedButton(
            onPressed: () {},
            splashColor: Color(0xFF0AD0B2),
            color: Color(0xFF0AD0B2),
            shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(22.0),
                    bottomLeft: Radius.circular(22.0),
                    topRight: Radius.circular(22.0),
                    bottomRight: Radius.circular(22.0))),
            child: Text(
              '完成',
              style: TextStyle(color: Color(0xFFFFFFFF)),
            ),
          ))
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        elevation: 0.0,
        iconTheme: IconThemeData(color: Colors.grey),
        //leading: Icon(Icons.arrow_back_ios),
        backgroundColor: Colors.white,
      ),
      body: Container(
        color: Colors.white,
        child: Align(
          child: Column(
            children: <Widget>[
              topText,
              showHigh(),
              Container(
                margin: EdgeInsets.only(top: 20.0),
                child: NumberPicker.integer(
                    initialValue: wight,
                    minValue: 30,
                    maxValue: 100,
                    onChanged: (newValue) {
                      setState(() {
                        wight = newValue;
                      });
                    }),
              ),
              Align(
                alignment: Alignment.bottomCenter,
                child: bottom2Btn(),
              )
            ],
          ),
        ),
      ),
    );
  }
}
